<template>
	<view class="list-item">
		<view class="list-item-left">
			<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="changeState()"></radio>
			<image :src="goods.goods_small_logo||defultPic" ></image>
		</view>
		<view class="list-item-right">
			<view class="list-item-right-name">{{goods.goods_name}}</view>
			<view class="list-item-right-bottom">
				<view class="list-item-right-price">￥{{goods.goods_price}}</view>
				<uni-number-box :min="1" :value="goods.goods_count" v-if="showNum" @change="changeNum"></uni-number-box>
			</view>
		</view>
	</view>	
</template>

<script>
	export default {
		props:{
			goods:{
				type: Object,
				default:{}
			},
			showRadio:{
				type:Object,
				//默认不会展示
				default:false
			},
			showNum:{
				type:Object,
				//默认不会展示
				default:false
			}
		},
		data() {
			return {
				//默认图片链接
				defultPic:''
			};
		},
		methods:{
			changeState(){
				this.$emit('radio-change',{
					goods_id:this.goods.goods_id,
					goods_state:!this.goods.goods_state,
				})
			},
			//监听到数量变化
			changeNum(value){
				this.$emit('num-change',{
					goods_id:this.goods.goods_id,
					goods_count: +value
				})
			}
		}
	}
</script>

<style lang="scss">
	.list-item{
		width: 750rpx;
		box-sizing: border-box;
		display: flex;
		padding: 10px 5px;
		border: 1px solid #efefef;
		.list-item-left{
			margin-right: 5px;
			display: flex;
			justify-content: space-between;
			align-items: center;
			image{
				width: 100px;
				height: 100px;
				display: block;
			}
		}
		.list-item-right{
			display: flex;
			flex: 1;
			flex-direction: column;
			justify-content: space-between;
			.list-item-right-name{
				
			}
			.list-item-right-bottom{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.list-item-right-price{
				color: #C00000;
				font-size: 16px;
				}
			}
			
		}
	}
</style>
